home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue40 / Clinic / RestartSampleFormU.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-10-12  |  1.7 KB  |  71 lines

  1. unit RestartSampleFormU;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     Button2: TButton;
  13.     Button3: TButton;
  14.     Button4: TButton;
  15.     procedure Button1Click(Sender: TObject);
  16.     procedure Button2Click(Sender: TObject);
  17.     procedure Button3Click(Sender: TObject);
  18.     procedure Button4Click(Sender: TObject);
  19.   private
  20.     { Private declarations }
  21.   public
  22.     { Public declarations }
  23.   end;
  24.  
  25. var
  26.   Form1: TForm1;
  27.  
  28. implementation
  29.  
  30. {$R *.DFM}
  31.  
  32. function RestartDialog(hwndOwner: HWnd;
  33.   lpstrReason: PChar; uFlags: UINT): Integer; stdcall;
  34. external 'Shell32.Dll' index 59;
  35.  
  36. function RestartDialogW(hwndOwner: HWnd;
  37.   lpstrReason: PWideChar; uFlags: UINT): Integer; stdcall;
  38. external 'Shell32.Dll' index 59;
  39.  
  40. procedure TForm1.Button1Click(Sender: TObject);
  41. begin
  42.   RestartDialog(Handle, nil, ewx_ShutDown)
  43. end;
  44.  
  45. procedure TForm1.Button2Click(Sender: TObject);
  46. begin
  47.   RestartDialog(Handle, nil, ew_RestartWindows)
  48. end;
  49.  
  50. procedure TForm1.Button3Click(Sender: TObject);
  51. const
  52.   Msg = 'I have played with your registry!'#13#13;
  53. begin
  54.   if Win32Platform = VER_PLATFORM_WIN32_WINDOWS then
  55.     RestartDialog(Handle, Msg, ew_RestartWindows)
  56.   else
  57.     RestartDialogW(Handle, Msg, ew_RestartWindows)
  58. end;
  59.  
  60. procedure TForm1.Button4Click(Sender: TObject);
  61. begin
  62.   if Win32Platform = VER_PLATFORM_WIN32_WINDOWS then
  63.     RestartDialog(Handle, '#I have played with your registry!'#13#13 +
  64.       'Restart Windows 95?', ew_RestartWindows)
  65.   else
  66.     RestartDialogW(Handle, '#I have played with your registry!'#13#13 +
  67.       'Restart Windows NT?', ew_RestartWindows)
  68. end;
  69.  
  70. end.
  71.